package com.jt.provider.controller;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;


@Component
public class DefaultRequestOriginParser implements RequestOriginParser {
    /**
     * 这个方法中基于业务规则对请求数据进行解析
     * @param request
     * @return
     */
    @Override
    public String parseOrigin(HttpServletRequest request) {
        //对请求参数进行解析,并返回参数的值,将这个值应用在sentinel的授权规则中
        //http://ip:port/path?origin=xxx
        String origin = request.getParameter("origin");
        return origin;
    }
}
